package com.wms.service.impl;

import com.wms.entity.WStock;
import com.wms.dao.WStockDao;
import com.wms.mytool.Result;
import com.wms.service.WStockService;
import com.wms.vo.WStockInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 仓库库存表(WStock)表服务实现类
 *
 * @author makejava
 * @since 2023-10-20 17:21:06
 */
@Service("wStockService")
public class WStockServiceImpl implements WStockService {
    @Resource
    private WStockDao wStockDao;


    @Override
    public Result selectAllStock() {
        List<WStockInfo> wStockInfos = this.wStockDao.selectAllStockInfo();
        if (wStockInfos != null) {
            return new Result(200, wStockInfos, "查询成功");
        } else {
            return new Result(200, "null", "查询失败");
        }
    }

    @Override
    public Result addStock(WStock wStock) {
        return null;
    }

    @Override
    public WStock selectByPidSid(Integer pid, Integer sid) {
        return this.wStockDao.selectByPidSid(pid, sid);
    }

    @Override
    public Result updateStock(WStock wStock) {
        wStock.setUpdateTime(new Date());
        int i = this.wStockDao.updateById(wStock);
        if (i == 1) {
            return new Result(200, i, "修改成功");
        } else {
            return new Result(400, null, "修改失败");
        }
    }

    @Override
    public Result selectBySid(Integer sid) {
        return new Result(200,this.wStockDao.selectBySid(sid),"success");
    }
}
